<!DOCTYPE html><html class=split lang=en-US-x-hixie><script src=../link-fixup.js defer=""></script>
<!-- Mirrored from html.spec.whatwg.org/dev/common-microsyntaxes.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 10 Sep 2025 08:36:24 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<meta charset=utf-8><meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name=viewport><title>HTML Standard, Edition for Web Developers</title><meta content=#3c790a name=theme-color><meta content="light dark" name=color-scheme><link rel=stylesheet href=../../resources.whatwg.org/standard-shared-with-dev.css crossorigin=""><link rel=icon href=https://resources.whatwg.org/logo.svg crossorigin=""><link rel=stylesheet href=styles.css crossorigin=""><script>
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
   function setLinkFragment(link) {
     link.hash = location.hash;
   }
  </script><body>
  <script async="" src=search.js></script>
  
  
  <header id=head class="head with-buttons">
   <a href=https://whatwg.org/ class=logo><img width=100 alt=WHATWG crossorigin="" class=darkmode-aware src=https://resources.whatwg.org/logo.svg height=100></a>
   
   <hgroup><h1><a rel=home href=index.html>HTML: The Living Standard</a></h1><p id=dev-edition-h2>Edition for Web Developers — Last Updated <span class=pubdate>10 September 2025</span></hgroup>
   

   <div id=search>
    <input placeholder="Search. Press '/'" autocomplete=off name=query id=query type=search>
    <ol id=results></ol>
   </div>
  </header>

  

  

  

  
  

  
  

  

  <nav><a href=infrastructure.html>← 2 Common infrastructure</a> — <a href=index.html>Table of Contents</a> — <a href=urls-and-fetching.html>2.4 URLs →</a></nav><ol class=toc><li><ol><li><a href=common-microsyntaxes.html#common-microsyntaxes><span class=secno>2.3</span> Common microsyntaxes</a><ol><li><a href=common-microsyntaxes.html#boolean-attributes><span class=secno>2.3.1</span> Boolean attributes</a><li><a href=common-microsyntaxes.html#keywords-and-enumerated-attributes><span class=secno>2.3.2</span> Keywords and enumerated attributes</a><li><a href=common-microsyntaxes.html#numbers><span class=secno>2.3.3</span> Numbers</a><ol><li><a href=common-microsyntaxes.html#signed-integers><span class=secno>2.3.3.1</span> Signed integers</a><li><a href=common-microsyntaxes.html#non-negative-integers><span class=secno>2.3.3.2</span> Non-negative integers</a><li><a href=common-microsyntaxes.html#floating-point-numbers><span class=secno>2.3.3.3</span> Floating-point numbers</a><li><a href=common-microsyntaxes.html#lists-of-floating-point-numbers><span class=secno>2.3.3.4</span> Lists of floating-point numbers</a></ol><li><a href=common-microsyntaxes.html#dates-and-times><span class=secno>2.3.4</span> Dates and times</a><ol><li><a href=common-microsyntaxes.html#months><span class=secno>2.3.4.1</span> Months</a><li><a href=common-microsyntaxes.html#dates><span class=secno>2.3.4.2</span> Dates</a><li><a href=common-microsyntaxes.html#yearless-dates><span class=secno>2.3.4.3</span> Yearless dates</a><li><a href=common-microsyntaxes.html#times><span class=secno>2.3.4.4</span> Times</a><li><a href=common-microsyntaxes.html#local-dates-and-times><span class=secno>2.3.4.5</span> Local dates and times</a><li><a href=common-microsyntaxes.html#time-zones><span class=secno>2.3.4.6</span> Time zones</a><li><a href=common-microsyntaxes.html#global-dates-and-times><span class=secno>2.3.4.7</span> Global dates and times</a><li><a href=common-microsyntaxes.html#weeks><span class=secno>2.3.4.8</span> Weeks</a><li><a href=common-microsyntaxes.html#durations><span class=secno>2.3.4.9</span> Durations</a><li><a href=common-microsyntaxes.html#vaguer-moments-in-time><span class=secno>2.3.4.10</span> Vaguer moments in time</a></ol><li><a href=common-microsyntaxes.html#space-separated-tokens><span class=secno>2.3.5</span> Space-separated tokens</a><li><a href=common-microsyntaxes.html#comma-separated-tokens><span class=secno>2.3.6</span> Comma-separated tokens</a><li><a href=common-microsyntaxes.html#syntax-references><span class=secno>2.3.7</span> References</a><li><a href=common-microsyntaxes.html#mq><span class=secno>2.3.8</span> Media queries</a><li><a href=common-microsyntaxes.html#unique-values><span class=secno>2.3.9</span> Unique internal values</a></ol></ol></ol><h3 id=common-microsyntaxes><span class=secno>2.3</span> Common microsyntaxes<a href=#common-microsyntaxes class=self-link></a></h3>

  <p>There are various places in HTML that accept particular data types, such as dates or numbers.
  This section describes what the conformance criteria for content in those formats is, and how to
  parse them.</p>

  


  



  <h4 id=boolean-attributes><span class=secno>2.3.1</span> Boolean attributes<a href=#boolean-attributes class=self-link></a></h4>

  <p>A number of attributes are <dfn id=boolean-attribute>boolean attributes</dfn>. The
  presence of a boolean attribute on an element represents the true value, and the absence of the
  attribute represents the false value.</p>

  <p>If the attribute is present, its value must either be the empty string or a value that is an
  <a id=boolean-attributes:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the attribute's canonical name, with no leading or
  trailing whitespace.</p>

  <p class=note>The values "true" and "false" are not allowed on boolean attributes. To represent
  a false value, the attribute has to be omitted altogether.</p>

  <div class=example>

   <p>Here is an example of a checkbox that is checked and disabled. The <code id=boolean-attributes:attr-input-checked><a href=input.html#attr-input-checked>checked</a></code> and <code id=boolean-attributes:attr-fe-disabled><a href=form-control-infrastructure.html#attr-fe-disabled>disabled</a></code>
   attributes are the boolean attributes.</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>label</c-><c- p>&gt;&lt;</c-><c- f>input</c-> <c- e>type</c-><c- o>=</c-><c- s>checkbox</c-> <c- e>checked</c-> <c- e>name</c-><c- o>=</c-><c- s>cheese</c-> <c- e>disabled</c-><c- p>&gt;</c-> Cheese<c- p>&lt;/</c-><c- f>label</c-><c- p>&gt;</c-></code></pre>

   <p>This could be equivalently written as this:

   <pre><code class='html'><c- p>&lt;</c-><c- f>label</c-><c- p>&gt;&lt;</c-><c- f>input</c-> <c- e>type</c-><c- o>=</c-><c- s>checkbox</c-> <c- e>checked</c-><c- o>=</c-><c- s>checked</c-> <c- e>name</c-><c- o>=</c-><c- s>cheese</c-> <c- e>disabled</c-><c- o>=</c-><c- s>disabled</c-><c- p>&gt;</c-> Cheese<c- p>&lt;/</c-><c- f>label</c-><c- p>&gt;</c-></code></pre>

   <p>You can also mix styles; the following is still equivalent:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>label</c-><c- p>&gt;&lt;</c-><c- f>input</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;checkbox&apos;</c-> <c- e>checked</c-> <c- e>name</c-><c- o>=</c-><c- s>cheese</c-> <c- e>disabled</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;</c-> Cheese<c- p>&lt;/</c-><c- f>label</c-><c- p>&gt;</c-></code></pre>

  </div>



  <h4 id=keywords-and-enumerated-attributes><span class=secno>2.3.2</span> Keywords and enumerated attributes<a href=#keywords-and-enumerated-attributes class=self-link></a></h4>

  <p>Some attributes, called <dfn id=enumerated-attribute data-lt="enumerated attribute" data-export="">enumerated attributes</dfn>, take on a finite set of states. The state for such an
  attribute is derived by combining the attribute's value, a set of keyword/state mappings given in
  the specification of each attribute, and two possible special states that can also be given in the
  specification of the attribute. These special states are the <dfn id=invalid-value-default><i>invalid value
  default</i></dfn> and the <dfn id=missing-value-default><i>missing value default</i></dfn>.</p>

  <p class=note>Multiple keywords can map to the same state.</p>

  <p class=note>The empty string can be a valid keyword. Note that the <i id=keywords-and-enumerated-attributes:missing-value-default><a href=#missing-value-default>missing value default</a></i> applies only when the attribute is <em>missing</em>, not when
  it is present with an empty string value.</p>

  <p>To determine the state of an attribute, use the following steps:</p>

  <ol><li>
    <p>If the attribute is not specified:</p>

    <ol><li><p>If the attribute has a <i id=keywords-and-enumerated-attributes:missing-value-default-2><a href=#missing-value-default>missing value default</a></i>
     state defined, then return that <i id=keywords-and-enumerated-attributes:missing-value-default-3><a href=#missing-value-default>missing value default</a></i>
     state.<li><p>Otherwise, return no state.</ol>
   <li><p>If the attribute's value is an <a id=keywords-and-enumerated-attributes:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for one of the
   keywords defined for the attribute, then return the state represented by that keyword.<li><p>If the attribute has an <i id=keywords-and-enumerated-attributes:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> state
   defined, then return that <i id=keywords-and-enumerated-attributes:invalid-value-default-2><a href=#invalid-value-default>invalid value default</a></i>
   state.<li><p>Return no state.</ol>

  <p>For authoring conformance purposes, if an enumerated attribute is specified, the attribute's
  value must be an <a id=keywords-and-enumerated-attributes:ascii-case-insensitive-2 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for one of the conforming keywords for
  that attribute, with no leading or trailing whitespace.</p>

  <p>For <a href=common-dom-interfaces.html#reflect id=keywords-and-enumerated-attributes:reflect>reflection</a> purposes, states which have any keywords mapping
  to them are said to have a <dfn id=canonical-keyword>canonical keyword</dfn>. This is determined as follows:</p>

  <ol><li><p>If there is only one keyword mapping to the given state, then it is that keyword.<li><p>If there is only one <em>conforming</em> keyword mapping to the given state, then it is
   that conforming keyword.<li><p>If there are two conforming keywords mapping to the given state, and one is the empty
   string, then the canonical keyword will be the conforming keyword that is not the empty
   string.<li><p>Otherwise, the canonical keyword for the state will be explicitly given in the
   specification for the attribute.</ol>



  <h4 id=numbers><span class=secno>2.3.3</span> Numbers<a href=#numbers class=self-link></a></h4>

  <h5 id=signed-integers><span class=secno>2.3.3.1</span> Signed integers<a href=#signed-integers class=self-link></a></h5>

  <p>A string is a <dfn id=valid-integer>valid integer</dfn> if it consists of one or more <a id=signed-integers:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>,
  optionally prefixed with a U+002D HYPHEN-MINUS character (-).</p>

  <p>A <a href=#valid-integer id=signed-integers:valid-integer>valid integer</a> without a U+002D HYPHEN-MINUS (-) prefix represents the number
  that is represented in base ten by that string of digits. A <a href=#valid-integer id=signed-integers:valid-integer-2>valid integer</a>
  <em>with</em> a U+002D HYPHEN-MINUS (-) prefix represents the number represented in base ten by
  the string of digits that follows the U+002D HYPHEN-MINUS, subtracted from zero.</p>

  


  <h5 id=non-negative-integers><span class=secno>2.3.3.2</span> Non-negative integers<a href=#non-negative-integers class=self-link></a></h5>

  <p>A string is a <dfn id=valid-non-negative-integer>valid non-negative integer</dfn> if it consists of one or more <a id=non-negative-integers:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII
  digits</a>.</p>

  <p>A <a href=#valid-non-negative-integer id=non-negative-integers:valid-non-negative-integer>valid non-negative integer</a> represents the number that is represented in base ten
  by that string of digits.</p>

  


  <h5 id=floating-point-numbers><span class=secno>2.3.3.3</span> Floating-point numbers<a href=#floating-point-numbers class=self-link></a></h5>

  <p>A string is a <dfn id=valid-floating-point-number>valid floating-point number</dfn> if it consists of:</p>

  <ol><li><p>Optionally, a U+002D HYPHEN-MINUS character (-).<li>
    <p>One or both of the following, in the given order:</p>

    <ol><li><p>A series of one or more <a id=floating-point-numbers:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>.<li>
      <p>Both of the following, in the given order:</p>

      <ol><li><p>A single U+002E FULL STOP character (.).<li><p>A series of one or more <a id=floating-point-numbers:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>.</ol>
     </ol>
   <li>
    <p>Optionally:</p>

    <ol><li><p>Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E
     character (E).<li><p>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character
     (+).<li><p>A series of one or more <a id=floating-point-numbers:ascii-digits-3 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>.</ol>
   </ol>

  <p>A <a href=#valid-floating-point-number id=floating-point-numbers:valid-floating-point-number>valid floating-point number</a> represents the number obtained by multiplying the
  significand by ten raised to the power of the exponent, where the significand is the first number,
  interpreted as base ten (including the decimal point and the number after the decimal point, if
  any, and interpreting the significand as a negative number if the whole string starts with a
  U+002D HYPHEN-MINUS character (-) and the number is not zero), and where the exponent is the
  number after the E, if any (interpreted as a negative number if there is a U+002D HYPHEN-MINUS
  character (-) between the E and the number and the number is not zero, or else ignoring a U+002B
  PLUS SIGN character (+) between the E and the number if there is one). If there is no E, then the
  exponent is treated as zero.</p>

  <p class=note>The Infinity and Not-a-Number (NaN) values are not <a href=#valid-floating-point-number id=floating-point-numbers:valid-floating-point-number-2>valid floating-point numbers</a>.</p>

  





  <h5 id=lists-of-floating-point-numbers><span class=secno>2.3.3.4</span> Lists of floating-point numbers<a href=#lists-of-floating-point-numbers class=self-link></a></h5>

  <p>A <dfn id=valid-list-of-floating-point-numbers>valid list of floating-point numbers</dfn> is a number of <a href=#valid-floating-point-number id=lists-of-floating-point-numbers:valid-floating-point-number>valid floating-point numbers</a> separated by U+002C COMMA characters,
  with no other characters (e.g. no <a id=lists-of-floating-point-numbers:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>). In addition, there might be
  restrictions on the number of floating-point numbers that can be given, or on the range of values
  allowed.</p>

  

  


  <h4 id=dates-and-times><span class=secno>2.3.4</span> Dates and times<a href=#dates-and-times class=self-link></a></h4>

  <p>In the algorithms below, the <dfn id=number-of-days-in-month-month-of-year-year>number of days in month <var>month</var> of year
  <var>year</var></dfn> is: <em>31</em> if <var>month</var> is 1, 3, 5, 7, 8,
  10, or 12; <em>30</em> if <var>month</var> is 4, 6, 9, or 11; <em>29</em> if <var>month</var> is 2
  and <var>year</var> is a number divisible by 400, or if <var>year</var> is a number divisible by 4
  but not by 100; and <em>28</em> otherwise. This takes into account leap years in the Gregorian
  calendar. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>When <a id=dates-and-times:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> are used in the date and time syntaxes defined in this section,
  they express numbers in base ten.</p>

  

  <p>Where this specification refers to the <dfn id=proleptic-gregorian-calendar>proleptic Gregorian calendar</dfn>, it means the
  modern Gregorian calendar, extrapolated backwards to year 1. A date in the <a href=#proleptic-gregorian-calendar id=dates-and-times:proleptic-gregorian-calendar>proleptic
  Gregorian calendar</a>, sometimes explicitly referred to as a <dfn id=proleptic-gregorian-date>proleptic-Gregorian
  date</dfn>, is one that is described using that calendar even if that calendar was not in use at
  the time (or place) in question. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p class=note>The use of the Gregorian calendar as the wire format in this specification is an
  arbitrary choice resulting from the cultural biases of those involved in the decision. See also
  the section discussing <a href=forms.html#input-author-notes>date, time, and number formats</a> in forms
   and the <code id=dates-and-times:the-time-element><a href=text-level-semantics.html#the-time-element>time</a></code> element.</p>


  <h5 id=months><span class=secno>2.3.4.1</span> Months<a href=#months class=self-link></a></h5>

  <p>A <dfn id=concept-month>month</dfn> consists of a specific <a href=#proleptic-gregorian-date id=months:proleptic-gregorian-date>proleptic-Gregorian
  date</a> with no time-zone information and no date information beyond a year and a month.
  <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A string is a <dfn id=valid-month-string>valid month string</dfn> representing a year <var>year</var> and
  month <var>month</var> if it consists of the following components in the given order:</p>

  <ol><li>Four or more <a id=months:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>year</var>, where <var>year</var> > 0<li>A U+002D HYPHEN-MINUS character (-)<li>Two <a id=months:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the month <var>month</var>, in the range
   1 ≤ <var>month</var> ≤ 12</ol>

  


  <h5 id=dates><span class=secno>2.3.4.2</span> Dates<a href=#dates class=self-link></a></h5>

  <p>A <dfn id=concept-date>date</dfn> consists of a specific <a href=#proleptic-gregorian-date id=dates:proleptic-gregorian-date>proleptic-Gregorian
  date</a> with no time-zone information, consisting of a year, a month, and a day.
  <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A string is a <dfn id=valid-date-string>valid date string</dfn> representing a year <var>year</var>, month
  <var>month</var>, and day <var>day</var> if it consists of the following
  components in the given order:</p>

  <ol><li>A <a href=#valid-month-string id=dates:valid-month-string>valid month string</a>, representing <var>year</var> and <var>month</var><li>A U+002D HYPHEN-MINUS character (-)<li>Two <a id=dates:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>day</var>, in the range
   1 ≤ <var>day</var> ≤ <var>maxday</var> where <var>maxday</var> is the <a href=#number-of-days-in-month-month-of-year-year id=dates:number-of-days-in-month-month-of-year-year>number of
   days in the month <var>month</var> and year <var>year</var></a></ol>

  


  <h5 id=yearless-dates><span class=secno>2.3.4.3</span> Yearless dates<a href=#yearless-dates class=self-link></a></h5>

  <p>A <dfn id=concept-yearless-date>yearless date</dfn> consists of a Gregorian month and a
  day within that month, but with no associated year. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A string is a <dfn id=valid-yearless-date-string>valid yearless date string</dfn> representing a month <var>month</var> and a day <var>day</var> if it consists of the following components
  in the given order:</p>

  <ol><li>Optionally, two U+002D HYPHEN-MINUS characters (-)<li>Two <a id=yearless-dates:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the month <var>month</var>, in the range
   1 ≤ <var>month</var> ≤ 12<li>A U+002D HYPHEN-MINUS character (-)<li>Two <a id=yearless-dates:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>day</var>, in the range
   1 ≤ <var>day</var> ≤ <var>maxday</var> where <var>maxday</var> is the <a href=#number-of-days-in-month-month-of-year-year id=yearless-dates:number-of-days-in-month-month-of-year-year>number of
   days</a> in the month <var>month</var> and any arbitrary leap year (e.g. 4 or
   2000)</ol>

  <p class=note>In other words, if the <var>month</var> is "<code>02</code>",
  meaning February, then the day can be 29, as if the year was a leap year.</p>

  


  <h5 id=times><span class=secno>2.3.4.4</span> Times<a href=#times class=self-link></a></h5>

  <p>A <dfn id=concept-time>time</dfn> consists of a specific time with no time-zone
  information, consisting of an hour, a minute, a second, and a fraction of a second.</p>

  <p>A string is a <dfn id=valid-time-string>valid time string</dfn> representing an hour <var>hour</var>, a
  minute <var>minute</var>, and a second <var>second</var> if it consists of the
  following components in the given order:</p>

  <ol><li>Two <a id=times:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>hour</var>, in the range
   0 ≤ <var>hour</var> ≤ 23<li>A U+003A COLON character (:)<li>Two <a id=times:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>minute</var>, in the range
   0 ≤ <var>minute</var> ≤ 59<li>If <var>second</var> is nonzero, or optionally if <var>second</var> is
   zero:

    <ol><li>A U+003A COLON character (:)<li>Two <a id=times:ascii-digits-3 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the integer part of <var>second</var>,
     in the range 0 ≤ <var>s</var> ≤ 59<li>If <var>second</var> is not an integer, or optionally if <var>second</var> is an integer:

      <ol><li>A U+002E FULL STOP character (.)<li>One, two, or three <a id=times:ascii-digits-4 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the fractional part of <var>second</var></ol>
     </ol>
   </ol>

  <p class=note>The <var>second</var> component cannot be 60 or 61; leap seconds cannot
  be represented.</p>

  


  <h5 id=local-dates-and-times><span class=secno>2.3.4.5</span> Local dates and times<a href=#local-dates-and-times class=self-link></a></h5>

  <p>A <dfn id=concept-datetime-local>local date and time</dfn> consists of a specific
  <a href=#proleptic-gregorian-date id=local-dates-and-times:proleptic-gregorian-date>proleptic-Gregorian date</a>, consisting of a year, a month, and a day, and a time,
  consisting of an hour, a minute, a second, and a fraction of a second, but expressed without a
  time zone. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A string is a <dfn id=valid-local-date-and-time-string>valid local date and time string</dfn> representing a date and time if it
  consists of the following components in the given order:</p>

  <ol><li>A <a href=#valid-date-string id=local-dates-and-times:valid-date-string>valid date string</a> representing the date<li>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character<li>A <a href=#valid-time-string id=local-dates-and-times:valid-time-string>valid time string</a> representing the time</ol>

  <p>A string is a <dfn id=valid-normalised-local-date-and-time-string>valid
  normalized local date and time string</dfn> representing a date and time if it consists of the
  following components in the given order:</p>

  <ol><li>A <a href=#valid-date-string id=local-dates-and-times:valid-date-string-2>valid date string</a> representing the date<li>A U+0054 LATIN CAPITAL LETTER T character (T)<li>A <a href=#valid-time-string id=local-dates-and-times:valid-time-string-2>valid time string</a> representing the time, expressed as the shortest possible
   string for the given time (e.g. omitting the seconds component entirely if the given time is zero
   seconds past the minute)</ol>

  


  <h5 id=time-zones><span class=secno>2.3.4.6</span> Time zones<a href=#time-zones class=self-link></a></h5>

  <p>A <dfn id=concept-timezone>time-zone offset</dfn> consists of a signed number of hours and
  minutes.</p>

  <p>A string is a <dfn id=valid-time-zone-offset-string>valid time-zone offset string</dfn> representing a time-zone offset if it
  consists of either:</p>


  <ul><li><p>A U+005A LATIN CAPITAL LETTER Z character (Z), allowed only if the time zone is
   UTC<li>
    <p>Or, the following components, in the given order:</p>

    <ol><li>Either a U+002B PLUS SIGN character (+) or, if the time-zone offset is not zero, a U+002D
     HYPHEN-MINUS character (-), representing the sign of the time-zone offset<li>Two <a id=time-zones:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the hours component <var>hour</var> of
     the time-zone offset, in the range 0 ≤ <var>hour</var> ≤ 23<li>Optionally, a U+003A COLON character (:)<li>Two <a id=time-zones:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the minutes component <var>minute</var> of the time-zone offset, in the range 0 ≤ <var>minute</var> ≤ 59</ol>
   </ul>

  <p class=note>This format allows for time-zone offsets from -23:59 to +23:59. Right now, in
  practice, the range of offsets of actual time zones is -12:00 to +14:00, and the minutes component
  of offsets of actual time zones is always either 00, 30, or 45. There is no guarantee that this
  will remain so forever, however, since time zones are used as political footballs and are thus
  subject to very whimsical policy decisions.</p>

  <p class=note>See also the usage notes and examples in the <a href=#concept-datetime id=time-zones:concept-datetime>global
  date and time</a> section below for details on using time-zone offsets with historical times
  that predate the formation of formal time zones.</p>

  


  <h5 id=global-dates-and-times><span class=secno>2.3.4.7</span> Global dates and times<a href=#global-dates-and-times class=self-link></a></h5>

  <p>A <dfn id=concept-datetime>global date and time</dfn> consists of a specific
  <a href=#proleptic-gregorian-date id=global-dates-and-times:proleptic-gregorian-date>proleptic-Gregorian date</a>, consisting of a year, a month, and a day, and a time,
  consisting of an hour, a minute, a second, and a fraction of a second, expressed with a time-zone
  offset, consisting of a signed number of hours and minutes. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A string is a <dfn id=valid-global-date-and-time-string>valid global date and time string</dfn> representing a date, time, and a
  time-zone offset if it consists of the following components in the given order:</p>

  <ol><li>A <a href=#valid-date-string id=global-dates-and-times:valid-date-string>valid date string</a> representing the date<li>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character<li>A <a href=#valid-time-string id=global-dates-and-times:valid-time-string>valid time string</a> representing the time<li>A <a href=#valid-time-zone-offset-string id=global-dates-and-times:valid-time-zone-offset-string>valid time-zone offset string</a> representing the time-zone offset</ol>

  <p>Times in dates before the formation of UTC in the mid-twentieth century must be expressed and
  interpreted in terms of UT1 (contemporary Earth solar time at the 0° longitude), not UTC (the
  approximation of UT1 that ticks in SI seconds). Time before the formation of time zones must be
  expressed and interpreted as UT1 times with explicit time zones that approximate the contemporary
  difference between the appropriate local time and the time observed at the location of Greenwich,
  London.</p>

  <div class=example>

   <p>The following are some examples of dates written as <a href=#valid-global-date-and-time-string id=global-dates-and-times:valid-global-date-and-time-string>valid global date and time strings</a>.</p>

   <dl><dt>"<code>0037-12-13 00:00Z</code>"<dd>Midnight in areas using London time on the birthday of Nero (the Roman Emperor). See below
    for further discussion on which date this actually corresponds to.<dt>"<code>1979-10-14T12:00:00.001-04:00</code>"<dd>One millisecond after noon on October 14th 1979, in the time zone in use on the east coast
    of the USA during daylight saving time.<dt>"<code>8592-01-01T02:09+02:09</code>"<dd>Midnight UTC on the 1st of January, 8592. The time zone associated with that time is two
    hours and nine minutes ahead of UTC, which is not currently a real time zone, but is nonetheless
    allowed.</dl>

   <p>Several things are notable about these dates:</p>

   <ul><li>Years with fewer than four digits have to be zero-padded. The date "37-12-13" would not be a
    valid date.<li>If the "<code>T</code>" is replaced by a space, it must be a single space
    character. The string "<code>2001-12-21  12:00Z</code>" (with two spaces
    between the components) would not be parsed successfully.<li>To unambiguously identify a moment in time prior to the introduction of the Gregorian
    calendar (insofar as moments in time before the formation of UTC can be unambiguously
    identified), the date has to be first converted to the Gregorian calendar from the calendar in
    use at the time (e.g. from the Julian calendar). The date of Nero's birth is the 15th of
    December 37, in the Julian Calendar, which is the 13th of December 37 in the <a href=#proleptic-gregorian-calendar id=global-dates-and-times:proleptic-gregorian-calendar>proleptic
    Gregorian calendar</a>.<li>The time and time-zone offset components are not optional.<li>Dates before the year one can't be represented as a datetime in this version of HTML.<li>Times of specific events in ancient times are, at best, approximations, since time was not
    well coordinated or measured until relatively recent decades.<li>Time-zone offsets differ based on daylight saving time.</ul>

  </div>

  


  <h5 id=weeks><span class=secno>2.3.4.8</span> Weeks<a href=#weeks class=self-link></a></h5>

  <p>A <dfn id=concept-week>week</dfn> consists of a week-year number and a week number
  representing a seven-day period starting on a Monday. Each week-year in this calendaring system
  has either 52 or 53 such seven-day periods, as defined below. The seven-day period starting on the
  Gregorian date Monday December 29th 1969 (1969-12-29) is defined as week number 1 in week-year
  1970. Consecutive weeks are numbered sequentially. The week before the number 1 week in a
  week-year is the last week in the previous week-year, and vice versa. <a href=references.html#refsGREGORIAN>[GREGORIAN]</a></p>

  <p>A week-year with a number <var>year</var> has 53 weeks if it corresponds to either a
  year <var>year</var> in the <a href=#proleptic-gregorian-calendar id=weeks:proleptic-gregorian-calendar>proleptic Gregorian calendar</a> that has a Thursday
  as its first day (January 1st), or a year <var>year</var> in the <a href=#proleptic-gregorian-calendar id=weeks:proleptic-gregorian-calendar-2>proleptic
  Gregorian calendar</a> that has a Wednesday as its first day (January 1st) and where <var>year</var> is a number divisible by 400, or a number divisible by 4 but not by 100. All
  other week-years have 52 weeks.</p>

  <p>The <dfn id=week-number-of-the-last-day>week number of the last day</dfn> of a week-year with 53 weeks is 53; the week number
  of the last day of a week-year with 52 weeks is 52.</p>

  <p class=note>The week-year number of a particular day can be different than the number of the
  year that contains that day in the <a href=#proleptic-gregorian-calendar id=weeks:proleptic-gregorian-calendar-3>proleptic Gregorian calendar</a>. The first week in a
  week-year <var>y</var> is the week that contains the first Thursday of the Gregorian year
  <var>y</var>.</p>

  <p class=note>For modern purposes, a <a href=#concept-week id=weeks:concept-week>week</a> as defined here is
  equivalent to ISO weeks as defined in ISO 8601. <a href=references.html#refsISO8601>[ISO8601]</a></p>

  <p>A string is a <dfn id=valid-week-string>valid week string</dfn> representing a week-year <var>year</var>
  and week <var>week</var> if it consists of the following components in the given
  order:</p>

  <ol><li>Four or more <a id=weeks:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing <var>year</var>, where <var>year</var> > 0<li>A U+002D HYPHEN-MINUS character (-)<li>A U+0057 LATIN CAPITAL LETTER W character (W)<li>Two <a id=weeks:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing the week <var>week</var>, in the range
   1 ≤ <var>week</var> ≤ <var>maxweek</var>, where <var>maxweek</var> is the <a href=#week-number-of-the-last-day id=weeks:week-number-of-the-last-day>week number of the last day</a> of week-year <var>year</var></ol>

  


  <h5 id=durations><span class=secno>2.3.4.9</span> Durations<a href=#durations class=self-link></a></h5>

  

  <p>A <dfn id=concept-duration>duration</dfn> consists of  a number of seconds.</p>

  <p class=note>Since months and seconds are not comparable (a month is not a precise number of
  seconds, but is instead a period whose exact length depends on the precise day from which it is
  measured) a <a href=#concept-duration id=durations:concept-duration>duration</a> as defined in this specification cannot
   include months (or years, which are equivalent to
  twelve months). Only durations that describe a specific number of seconds can be described.</p>

  <p>A string is a <dfn id=valid-duration-string>valid duration string</dfn> representing a <a href=#concept-duration id=durations:concept-duration-2>duration</a> <var>t</var> if it consists of either of the
  following:</p>

  <ul><li>
    

    

    <p>A literal U+0050 LATIN CAPITAL LETTER P character followed by one or more of the following
    subcomponents, in the order given, where the number of days, hours, minutes, and
    seconds corresponds to the same number of seconds as in <var>t</var>:</p>

    <ol><li><p>One or more <a id=durations:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> followed by a U+0044 LATIN CAPITAL LETTER D
     character, representing a number of days.<li>
      <p>A U+0054 LATIN CAPITAL LETTER T character followed by one or more of the following
      subcomponents, in the order given:</p>

      <ol><li><p>One or more <a id=durations:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> followed by a U+0048 LATIN CAPITAL LETTER H
       character, representing a number of hours.<li><p>One or more <a id=durations:ascii-digits-3 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> followed by a U+004D LATIN CAPITAL LETTER M
       character, representing a number of minutes.<li>
        <p>The following components:</p>

        <ol><li><p>One or more <a id=durations:ascii-digits-4 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing a number of seconds.<li><p>Optionally, a U+002E FULL STOP character (.) followed by one, two, or three
         <a id=durations:ascii-digits-5 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing a fraction of a second.<li><p>A U+0053 LATIN CAPITAL LETTER S character.</ol>
       </ol>
     </ol>

    <p class=note>This, as with a number of other date- and time-related microsyntaxes defined in
    this specification, is based on one of the formats defined in ISO 8601. <a href=references.html#refsISO8601>[ISO8601]</a></p>
   <li>
    <p>One or more <a href=#duration-time-component id=durations:duration-time-component>duration time components</a>, each with
    a different <a href=#duration-time-component-scale id=durations:duration-time-component-scale>duration time component scale</a>, in any order; the sum of the represented
    seconds being equal to the number of seconds in <var>t</var>.</p>

    <p>A <dfn id=duration-time-component>duration time component</dfn> is a string consisting of the following components:</p>

    <ol><li><p>Zero or more <a id=durations:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>.<li><p>One or more <a id=durations:ascii-digits-6 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing a number of time units, scaled by
     the <a href=#duration-time-component-scale id=durations:duration-time-component-scale-2>duration time component scale</a> specified (see below) to represent a number of
     seconds.<li><p>If the <a href=#duration-time-component-scale id=durations:duration-time-component-scale-3>duration time component scale</a> specified is 1 (i.e. the units are
     seconds), then, optionally, a U+002E FULL STOP character (.) followed by one, two, or three
     <a id=durations:ascii-digits-7 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, representing a fraction of a second.<li><p>Zero or more <a id=durations:space-characters-2 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>.<li>
      <p>One of the following characters, representing the <dfn id=duration-time-component-scale>duration time component scale</dfn>
      of the time unit used in the numeric part of the <a href=#duration-time-component id=durations:duration-time-component-2>duration time component</a>:</p>

      <dl><dt>U+0057 LATIN CAPITAL LETTER W character<dt>U+0077 LATIN SMALL LETTER W character<dd>Weeks. The scale is 604800.<dt>U+0044 LATIN CAPITAL LETTER D character<dt>U+0064 LATIN SMALL LETTER D character<dd>Days. The scale is 86400.<dt>U+0048 LATIN CAPITAL LETTER H character<dt>U+0068 LATIN SMALL LETTER H character<dd>Hours. The scale is 3600.<dt>U+004D LATIN CAPITAL LETTER M character<dt>U+006D LATIN SMALL LETTER M character<dd>Minutes. The scale is 60.<dt>U+0053 LATIN CAPITAL LETTER S character<dt>U+0073 LATIN SMALL LETTER S character<dd>Seconds. The scale is 1.</dl>
     <li><p>Zero or more <a id=durations:space-characters-3 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>.</ol>

    <p class=note>This is not based on any of the formats in ISO 8601. It is intended to be a more
    human-readable alternative to the ISO 8601 duration format.</p>
   </ul>

  


  <h5 id=vaguer-moments-in-time><span class=secno>2.3.4.10</span> Vaguer moments in time<a href=#vaguer-moments-in-time class=self-link></a></h5>

  <p>A string is a <dfn id=valid-date-string-with-optional-time>valid date string with optional time</dfn> if
  it is also one of the following:</p>

  <ul><li>A <a href=#valid-date-string id=vaguer-moments-in-time:valid-date-string>valid date string</a><li>A <a href=#valid-global-date-and-time-string id=vaguer-moments-in-time:valid-global-date-and-time-string>valid global date and time string</a></ul>

  


  



  <h4 id=space-separated-tokens><span class=secno>2.3.5</span> Space-separated tokens<a href=#space-separated-tokens class=self-link></a></h4>

  <p>A <dfn id=set-of-space-separated-tokens data-export="">set of space-separated tokens</dfn> is a string containing zero or more words
  (known as tokens) separated by one or more <a id=space-separated-tokens:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>, where words consist of
  any string of one or more characters, none of which are <a id=space-separated-tokens:space-characters-2 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>.</p>

  <p>A string containing a <a href=#set-of-space-separated-tokens id=space-separated-tokens:set-of-space-separated-tokens>set of space-separated tokens</a> may have leading or trailing
  <a id=space-separated-tokens:space-characters-3 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>.</p>

  <p>An <dfn id=unordered-set-of-unique-space-separated-tokens data-export="">unordered set of unique space-separated tokens</dfn> is a <a href=#set-of-space-separated-tokens id=space-separated-tokens:set-of-space-separated-tokens-2>set of
  space-separated tokens</a> where none of the tokens are duplicated.</p>

  <p>An <dfn id=ordered-set-of-unique-space-separated-tokens>ordered set of unique space-separated tokens</dfn> is a <a href=#set-of-space-separated-tokens id=space-separated-tokens:set-of-space-separated-tokens-3>set of space-separated
  tokens</a> where none of the tokens are duplicated but where the order of the tokens is
  meaningful.</p>

  <p><a href=#set-of-space-separated-tokens id=space-separated-tokens:set-of-space-separated-tokens-4>Sets of space-separated tokens</a> sometimes
  have a defined set of allowed values. When a set of allowed values is defined, the tokens must all
  be from that list of allowed values; other values are non-conforming. If no such set of allowed
  values is provided, then all values are conforming.</p>

  <p class=note>How tokens in a <a href=#set-of-space-separated-tokens id=space-separated-tokens:set-of-space-separated-tokens-5>set of space-separated tokens</a> are to be compared
  (e.g. case-sensitively or not) is defined on a per-set basis.</p>



  <h4 id=comma-separated-tokens><span class=secno>2.3.6</span> Comma-separated tokens<a href=#comma-separated-tokens class=self-link></a></h4>

  <p>A <dfn id=set-of-comma-separated-tokens>set of comma-separated tokens</dfn> is a string containing zero or more tokens each
  separated from the next by a single U+002C COMMA character (,), where tokens consist of any string
  of zero or more characters, neither beginning nor ending with <a id=comma-separated-tokens:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>, nor
  containing any U+002C COMMA characters (,), and optionally surrounded by <a id=comma-separated-tokens:space-characters-2 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII
  whitespace</a>.</p>

  <p class=example>For instance, the string "<code> a ,b,,d d </code>" consists of four tokens: "a", "b", the empty
  string, and "d d". Leading and trailing whitespace around each token doesn't count as part of
  the token, and the empty string can be a token.</p>

  <p><a href=#set-of-comma-separated-tokens id=comma-separated-tokens:set-of-comma-separated-tokens>Sets of comma-separated tokens</a> sometimes
  have further restrictions on what consists a valid token. When such restrictions are defined, the
  tokens must all fit within those restrictions; other values are non-conforming. If no such
  restrictions are specified, then all values are conforming.</p>



  <h4 id=syntax-references><span class=secno>2.3.7</span> References<a href=#syntax-references class=self-link></a></h4>

  <p>A <dfn id=valid-hash-name-reference>valid hash-name reference</dfn> to an element of type <var>type</var> is a
  string consisting of a U+0023 NUMBER SIGN character (#) followed by a string which exactly matches
  the value of the <code>name</code> attribute of an element with type <var>type</var> in
  the same <a id=syntax-references:tree href=https://dom.spec.whatwg.org/#concept-tree data-x-internal=tree>tree</a>.</p>

  


  <h4 id=mq><span class=secno>2.3.8</span> Media queries<a href=#mq class=self-link></a></h4>

  <p>A string is a <dfn id=valid-media-query-list>valid media query list</dfn> if it matches the <code>&lt;media-query-list></code> production of <cite>Media Queries</cite>.
  <a href=references.html#refsMQ>[MQ]</a></p>

  <p>A string <dfn id=matches-the-environment>matches the environment</dfn> of the user if it is the empty string, a string
  consisting of only <a id=mq:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>, or is a media query list that matches the user's
  environment according to the definitions given in <cite>Media Queries</cite>. <a href=references.html#refsMQ>[MQ]</a></p>


  <h4 id=unique-values><span class=secno>2.3.9</span> Unique internal values<a href=#unique-values class=self-link></a></h4>

  <p>A <dfn id=unique-internal-value>unique internal value</dfn> is a value that is serializable, comparable by value, and
  never exposed to script.</p>

  <p>To create a <dfn id=new-unique-internal-value>new unique internal value</dfn>, return a <a href=#unique-internal-value id=unique-values:unique-internal-value>unique internal value</a>
  that has never previously been returned by this algorithm.</p>


  <nav><a href=infrastructure.html>← 2 Common infrastructure</a> — <a href=index.html>Table of Contents</a> — <a href=urls-and-fetching.html>2.4 URLs →</a></nav>
